def print_file_info(file_name):
    """接收传入文件的路径，打印文件的全部内容
    Args:
        file_name (str): 文件路径
    """
    f = None
    try:
        f = open(file_name,"r",encoding="UTF-8")
        content = f.read()
        print(f"文件的内容如下：\n{content}")
    except Exception as e:
        print(f"出错了:{e}")
    finally:
        if f:# 如果f成功open，那就不是False，则进入到此if中
            f.close()
            print("***\"print_file_info\"执行完毕***")

def append_to_file(file_name,data):
    """接受文件路径及传入数据，将数据追加写入到文件中
    Args:
        file_name (str): 文件路径
        data (str): 追加数据
    """
    f = None
    try:
        f = open(file_name,"a",encoding="UTF-8")
        f.write("\n" + data)
    except Exception as e:
        print(f"函数append_to_file出现错误：{e}")
    finally:
        if f:#如果f成功open，则为true
            #f.flush()
            f.close()
            print("***\"append_to_file\"执行完毕***")

if __name__ == "__main__":
    #仅在调试中触发
    print_file_info("F:/bli.txt")
    append_to_file("f:/gg.txt","wokao")